home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
dalla rivista
/
amiga.free
/
sorgenti vari
/
wolfedit2 2.0.4 source.sit
/
WolfEdit2 2.0.4 Source
/
UEditWalls.p
< prev
next >
Wrap
Text File
|
1995-11-03
|
5KB
|
213 lines
unit UEditWalls;
interface
uses
UWolfDoc;
procedure EditWalls (mapList: TMapListDoc);
implementation
uses
UEditArt;
const
wallEditDlogID = 131;
splitViewItem = 5;
northSouthItem = 6;
eastWestItem = 7;
shadeItem = 8;
mirrorItem = 9;
type
TWallImagePalette = object(TImagePalette)
procedure IWallImagePalette;
procedure DrawImage (itemNo: integer; r: Rect);
override;
function ItemSelectable (item: integer): boolean;
override;
end;
TWallEditDialog = object(TArtEditDialog)
fCurrentView: integer;
procedure IWallEditDialog (itsMapList: TMapListDoc);
procedure ItemHit (var e: EventInfo; itemNo: integer);
override;
procedure SelectView (viewNum: integer);
function Split: boolean;
function CurrentView: integer;
procedure UninstallArt;
override;
procedure InstallArt;
override;
function ArtImageType: CustomImageType;
override;
function ArtImageCode: integer;
override;
procedure TWallEditDialog.ChangeImage (gworld: GWorldPtr; isThumbnail: boolean);
override;
end;
procedure TWallImagePalette.IWallImagePalette;
begin
IImagePalette(16, 29);
fDialog := nil;
end;
procedure TWallImagePalette.DrawImage (itemNo: integer; r: Rect);
begin
fDialog.fMapList.PlotWall($81 + itemNo, r)
end;
function TWallImagePalette.ItemSelectable (item: integer): boolean;
begin
ItemSelectable := fDialog.fMapList.WallAvailable($81 + item);
end;
procedure TWallEditDialog.IWallEditDialog (itsMapList: TMapListDoc);
var
palette: TWallImagePalette;
begin
new(palette);
palette.IWallImagePalette;
IArtEditDialog(wallEditDlogID, palette, itsMapList, true);
fArtView.fRemoveWhite := true;
palette.fDialog := self;
DefineGroup(northSouthItem, eastWestItem);
fCurrentView := northSouthView;
end;
procedure TWallEditDialog.ItemHit (var e: EventInfo; itemNo: integer);
var
value: integer;
begin
inherited ItemHit(e, itemNo);
value := GetItemValue(itemNo);
case itemNo of
northSouthItem:
SelectView(northSouthView);
eastWestItem:
SelectView(eastWestView);
otherwise
;
end;
end;
procedure TWallEditDialog.SelectView (viewNum: integer);
begin
if viewNum <> fCurrentView then begin
UninstallArt;
fCurrentView := viewNum;
InstallArt;
end;
end;
function TWallEditDialog.Split: boolean;
begin
Split := GetItemValue(splitViewItem) <> 0;
end;
function TWallEditDialog.CurrentView: integer;
begin
if Split then
CurrentView := fCurrentView
else
CurrentView := bothViews;
end;
procedure TWallEditDialog.UninstallArt;
var
wal: WallArtListHandle;
i: integer;
procedure Uninstall (var this, other: WallArtListEntry);
var
code: integer;
view: integer;
begin
view := CurrentView;
if fArtView.fChanged then begin
if (this.art <> nil) & (this.art <> other.art) then
DisposHandle(this.art);
this.art := fArtView.ExtractWall;
if not Split then begin
if other.art <> nil then
DisposHandle(other.art);
other.art := this.art;
end;
fMapList.Changed;
fArtView.fChanged := false;
end;
UninstallFlag(this.darkFlag, shadeItem);
UninstallFlag(this.mirrorFlag, mirrorItem);
end;
begin {TWallEditDialog.UninstallArt}
if fCurrentArt >= 0 then begin
wal := fMapList.GetWallArtList;
HLock(Handle(wal));
i := 2 * fCurrentArt;
Uninstall(wal^^[i + fCurrentView], wal^^[i + 1 - fCurrentView]);
HUnlock(Handle(wal));
end;
end;
procedure TWallEditDialog.InstallArt;
var
wal: WallArtListHandle;
i: integer;
procedure Install (this, other: WallArtListEntry);
begin
fArtView.InstallWall(this.art);
InstallFlag(this.art <> other.art, splitViewItem);
InstallFlag(this.darkFlag, shadeItem);
InstallFlag(this.mirrorFlag, mirrorItem);
end;
begin {TWallEditDialog.InstallArt}
if fCurrentArt >= 0 then begin
wal := fMapList.GetWallArtList;
HLock(Handle(wal));
i := 2 * fCurrentArt;
Install(wal^^[i + fCurrentView], wal^^[i + 1 - fCurrentView]);
HUnlock(Handle(wal));
end;
end;
function TWallEditDialog.ArtImageType: CustomImageType;
begin
ArtImageType := wallImage;
end;
function TWallEditDialog.ArtImageCode: integer;
begin
ArtImageCode := $81 + fCurrentArt;
end;
procedure TWallEditDialog.ChangeImage (gworld: GWorldPtr; isThumbnail: boolean);
begin
fMapList.InstallWallImage(ArtImageCode, CurrentView, gworld);
end;
procedure EditWalls (mapList: TMapListDoc);
var
dlog: TWallEditDialog;
procedure CheckWindow (win: TWindow);
begin
if member(win, TWallEditDialog) then begin
win.Select;
exit(EditWalls);
end;
end;
begin {EditWalls}
mapList.EachWindowDo(CheckWindow);
new(dlog);
dlog.IWallEditDialog(mapList);
dlog.Show;
end;
end.